// components/playlist/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    playlist: Object,
  },

  observers: {

    'playlist.playCount': function(val) {
      let count = this._tranNumber(val, 2);
      this.setData({
        count
      });
    }

  },

  /**
   * 组件的初始数据
   */
  data: {
    count: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {


    _tranNumber(num, point) {
      let numStr = num.toString().split('.')[0];
      let length = numStr.length;
      if (numStr.length < 6) {
        return numStr;
      } else if (length >= 6 && length <= 8) {
        let decimal = numStr.substring(length - 4, length - 4 + point);
        return parseFloat(parseInt(num / 10000) + "." + decimal) + '万';
      } else {
        let decimal = numStr.substring(length - 8, length - 8 + point);
        return parseFloat(parseInt(num / 100000000) + "." + decimal) + '亿';
      }
    }

  }

})